<template>
  <div>
    <header>
      <van-icon name="arrow-left" />
      <span class="address">地址管理</span>
      <span class="save" @click="add">添加</span>
    </header>
    <van-address-list
      style="margin-top:10px"
      v-model="chosenAddressId"
      :list="list"
      :disabled-list="disabledList"
      disabled-text="以下地址超出配送范围"
      @add="onAdd"
      @edit="onEdit"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      chosenAddressId: "1",
      list: [
        {
          id: "1",
          name: "胡歌",
          tel: "00000000000",
          address: "广东省潮州市湘桥区帅哥路 xxx 号xxxx大厦 x 楼 xxx 室"
        },
        {
          id: "2",
          name: "李四",
          tel: "1310000000",
          address: "浙江省杭州市拱墅区莫干山路 50 号"
        }
      ],
      disabledList: [
        {
          id: "3",
          name: "王五",
          tel: "1320000000",
          address: "浙江省杭州市滨江区江南大道 15 号"
        }
      ]
    };
  },
  methods: {
    onAdd() {
      this.$router.push({
        path: "/address/add"
      });
    },
    add() {
      this.$router.push({
        path: "/address/add"
      });
    },
    onEdit() {
      this.$router.push({
        path: "/address/edit"
      });
    }
  }
};
</script>

<style lang="less" scoped>
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 44px;
  background: #fff;
  i {
    margin-left: 8px;
    font-size: 24px;
    vertical-align: middle;
  }
  .address {
    font-size: 17px;
    color: #2e2f30;
  }
  .save {
    font-size: 10px;
    color: #c53539;
    margin-right: 20px;
  }
}
</style>